<?php echo $header;?>
<div id="content">
  <div class="box">
   <div class="heading">
      <h1><img src="view/image/information.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a></div>
    </div>
     <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
		<table class="form">
	      <tr>
		    <td><span class="required">*</span> <?php echo "市、分局"; ?></td>
            	<td ><input readonly="readonly"  value="<?php echo '姑苏分局';?>"   id="so" name="so" >
			</td>
			</tr>
			<tr>
			<td><span class="required">*</span> <?php echo "派出所"; ?></td>
			 <td>
					<input readonly="readonly"  name="police_station" value="<?php echo '胥江派出所'; ?>">
				 </td>
			</tr>
			
			<tr>
			<td><span class="required">*</span> <?php echo "警务室名称"; ?></td>
			 <td>
					<input  name="police_office" value="<?php echo $police_office; ?>">
				 </td>
			</tr>
			
			<tr>
			<td><span class="required">*</span> <?php echo "所属社区"; ?></td>
			 <td>
					<select name="community_id">
						<option value="-1">请选择....</option>
						<?php foreach ($communities as $community) { ?>
							<option value="<?php echo $community['community_id'];?>" <?php if($community_id==$community['community_id']){?> selected="selected" <?php }?> ><?php echo $community['title'];?></option>
						<?php }?>
					</select>
				 </td>
			</tr>
			
			
			<tr>
			<td><span class="required">*</span> <?php echo "固定电话"; ?></td>
			 <td>
					<input  name="dianhua" value="<?php echo $dianhua; ?>">
				 </td>
			</tr>
			
			<tr>
			<td><span class="required">*</span> <?php echo "受理点详细地址"; ?></td>
			 <td>
					<textarea  name="address" cols="30" rows="5"><?php echo $address; ?></textarea>
				 </td>
			</tr>
        </table>
        
              
      	<table class="form" id="text">
	      <tr>
		    <td><span class="required">*</span> <?php echo "民警"; ?></td>
            	<td><input name="police_id_search" value="" type="text" />
			</td>
            </tr>
             <tr>
              <td>&nbsp;</td>
              <td><div id="police_route" class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php foreach ($polices as $police) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div id="police_route<?php echo $police['police_id']; ?>" class="<?php echo $class; ?>"><?php echo $police['title']; ?><img src="view/image/delete.png" alt="" />
                    <input type="hidden" name="police_route[]" value="<?php echo $police['police_id']; ?>" />
                  </div>
                  <?php } ?>
                </div></td>
            </tr>
        </table>
        
        <table class="form" id="text">
	      <tr>
		    <td><span class="required">*</span> <?php echo "辅警"; ?></td>
            	<td><input name="assistant_police_id_search" value="" type="text" />
			</td>
            </tr>
             <tr>
              <td>&nbsp;</td>
              <td><div id="assistant_police_route" class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php foreach ($assistant_polices as $assistant_police) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div id="assistant_police_route<?php echo $assistant_police['assistant_police_id']; ?>" class="<?php echo $class; ?>"><?php echo $assistant_police['title']; ?><img src="view/image/delete.png" alt="" />
                    <input type="hidden" name="assistant_police_route[]" value="<?php echo $assistant_police['assistant_police_id']; ?>" />
                  </div>
                  <?php } ?>
                </div></td>
            </tr>
        </table>
      </form>
      </div>
  </div>
  </div>
  
  <script type="text/javascript"><!--
$('input[name=\'police_id_search\']').autocomplete({
	delay: 500,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=community/police/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						label: item.title,
						value: item.police_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('#police_route' + ui.item.value).remove();
		
		$('#police_route').append('<div id="police_route' + ui.item.value + '">' + ui.item.label + '<img src="view/image/delete.png" alt="" /><input type="hidden" name="police_route[]" value="' + ui.item.value + '" /></div>');

		$('#police_route div:odd').attr('class', 'odd');
		$('#police_route div:even').attr('class', 'even');
				
		return false;
	},
	focus: function(event, ui) {
      return false;
   }
});
$('#police_route div img').live('click', function() {
	$(this).parent().remove();
	
	$('#police_route div:odd').attr('class', 'odd');
	$('#police_route div:even').attr('class', 'even');	
});
//--></script> 
  
  <script type="text/javascript"><!--
$('input[name=\'assistant_police_id_search\']').autocomplete({
	delay: 500,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=community/assistant_police/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						label: item.title,
						value: item.assistant_police_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('#assistant_police_route' + ui.item.value).remove();
		
		$('#assistant_police_route').append('<div id="assistant_police_route' + ui.item.value + '">' + ui.item.label + '<img src="view/image/delete.png" alt="" /><input type="hidden" name="assistant_police_route[]" value="' + ui.item.value + '" /></div>');

		$('#assistant_police_route div:odd').attr('class', 'odd');
		$('#assistant_police_route div:even').attr('class', 'even');
				
		return false;
	},
	focus: function(event, ui) {
      return false;
   }
});
$('#assistant_police_route div img').live('click', function() {
	$(this).parent().remove();
	
	$('#assistant_police_route div:odd').attr('class', 'odd');
	$('#assistant_police_route div:even').attr('class', 'even');	
});
//--></script> 
  
<script type="text/javascript" src="view/javascript/jquery/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="view/javascript/jquery/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript"><!--
$('.fancybox').fancybox({
	width: 860,
	height: 360,
	autoDimensions: true,
	scrolling: 'no',
	onClosed:function() {
		//location.reload();
	}
});
//--></script> 

<script type="text/javascript"><!--
function image_upload(field, thumb) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value')),
					dataType: 'text',
					success: function(text) {
						$('#' + thumb).replaceWith('<img src="' + text + '" alt="" id="' + thumb + '" />');
					}
				});
			}
		},	
		bgiframe: false,
		width: 800,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script> 

<?php echo $footer;?>
